package com.lcf.system.controller;


import cn.dev33.satoken.annotation.SaCheckPermission;
import com.lcf.system.dto.tenant.SysTenantDTO;
import com.lcf.system.dto.tenant.SysTenantEditDTO;
import com.lcf.system.service.SysTenantService;
import com.lcf.system.vo.tenant.SysTenantVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 租户(SysTenant)表控制层
 *
 * @author lcf
 * @since 2025-03-02 23:00:13
 */
@Tag(name = "租户")
@RestController
@RequestMapping("sysTenant")
public class SysTenantController {
    @Resource
    private SysTenantService sysTenantService;

    /**
     * 新增租户
     */
    @Operation(summary = "新增租户")
    @SaCheckPermission("sysTenant:add")
    @PostMapping
    public void add(@Validated @RequestBody SysTenantDTO dto) {
        sysTenantService.add(dto);
    }

    /**
     * 修改租户
     */
    @Operation(summary = "修改租户")
    @SaCheckPermission("sysTenant:edit")
    @PatchMapping
    public void edit(@Validated @RequestBody SysTenantEditDTO dto) {
        sysTenantService.edit(dto);
    }

    /**
     * 搜索租户
     */
    @Operation(summary = "搜索租户")
    @SaCheckPermission("sysTenant:search")
    @GetMapping("list/{tenantName}")
    public List<SysTenantVO> search(@Schema(description = "租户名称") @PathVariable String tenantName) {
        return sysTenantService.search(tenantName);
    }
    /**
     * 查询所有社区
     */
    @Operation(summary = "查询所有社区")
    @SaCheckPermission("sysTenant:search")
    @GetMapping("list")
    public List<SysTenantVO> getAll() {
        return sysTenantService.getList();
    }
}

